﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.Configuration;
using PUCIT.eFCS.Utility.Encryption;
using PUCIT.eFCS.Business;

namespace PUCIT.eFCS
{
    public partial class UpdateFormTemplate : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                Session["page"] = "UpdateFormTemplate.aspx";
                string encryptedQueryStringPrameters = (string)Session["params"];

                //Session.Remove("params");

                // Decrypt query strings parameters
                string cryptoKey = WebConfigurationManager.AppSettings["CryptoKey"];
                string decryptedQueryString = CryptoQueryStringHandler.DecryptQueryStrings(encryptedQueryStringPrameters, cryptoKey);

                string[] keyValuePair = decryptedQueryString.Split('='); // e.g. {documentId,15

                int documentId = int.Parse(keyValuePair[1]);

                BusinessClass eFCS = new BusinessClass();

                string documentName = eFCS.GetDocumentNameByDocumentId(documentId);
                string documentVersion = eFCS.GetDocumentVersionByDocumentId(documentId);
                string totalSections = eFCS.GetDocumentTotalSectionsByDocumentId(documentId);           //one number
                string completedSections = eFCS.GetDocumentCompletedSectionsByDocumentId(documentId);   //one number


                FormNamelbl.Text = documentName;

                float version = float.Parse(documentVersion);
                Session["version"] = version;
                Session["totalSections"] = totalSections;
                Session["completedSections"] = completedSections;
            }
        }
        protected void Button1_Click(object sender, EventArgs e)
        {
            String NoofSections = DDL.SelectedItem.Text;
            String FormName = FormNamelbl.Text;

            Session["DocumentName"] = FormName;
            Session["TotalSections"] = NoofSections;
            Response.Redirect("DesignStudentSection.aspx");
        }
    }
}